import java.util.Scanner;

/**
 * 挑7
 * Created by JiaJia on 2019/4/1 0001.
 */
public class HuaWei037 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int num = sc.nextInt();
            System.out.println(countSeven(num));
        }
        sc.close();
    }

    private static int countSeven(int number){
        int result =0;
        for (int i = 7; i <number ; i++) {
            if(i%7==0){
                result++;
            }else{
                int m=i;
                while (m!=0){
                    if(m%10==7){
                        result++;
                        break;
                    }else {
                        m=m/10;
                    }
                }
            }
        }

        return result;

    }

}